<template>
<el-dialog
:title="dialogTitle"
:visible.sync="dialogVisible"
width="30%"
:close-on-click-modal="false"
:before-close="handleClose">
  <el-form
  :model="auditForm"
  ref="auditForm"
  :rules="rules"
  label-width="100px">
    <el-form-item label="备注:" :prop="getIsNull? '' : 'remark'">
      <el-input type="textarea" rows="3" v-model="auditForm.remark" placeholder="请输入备注"></el-input>
    </el-form-item>
  </el-form>

  <span slot="footer" class="dialog-footer">
    <el-button @click="handleClose">取 消</el-button>
    <el-button type="primary" @click="handleConfirm">确 定</el-button>
  </span>
</el-dialog>
</template>
<script>
export default {
  name: 'GoodsAuditModel',
  props: {
    title: {
      type: String,
      default: ()=> ''
    },
    visible: {
      type: Boolean,
      default: ()=> false
    },
    dataId: {
      type: Number,
      default: ()=> null
    },
    funType: {
      type: Number,
      default: ()=> null
    },
    isNull: {
      type: Boolean,
      default: ()=> true
    }
  },
  data() {
    return {
      auditForm: {
        remark: null
      },
      rules: {
        remark: [{ required: true, message: '请输入审核摘要', trigger: 'blur, change' }]
      }
    }
  },
  computed: {
    dialogTitle: {
      get() {
        return this.title
      }
    },

    dialogVisible: {
      get() {
        return this.visible
      }
    },

    getIsNull: {
      get() {
        return this.isNull
      }
    }
  },
  methods: {
    handleConfirm() {
      this.$refs.auditForm.validate((valid) => {
        if (valid) {
          this.$emit('callBack', this.funType, this.dataId, { ...this.auditForm })
          this.handleClose()
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },

    handleClose() {
      this.$refs.auditForm.resetFields()
      this.$emit('update:visible', false)
    }
  }
}
</script>
<style lang="scss" scoped>

</style>